#include "log.h"
#include "stdio.h"

#define MAX_PRINTED_BIN_LENGTH (64)
void LOG_Binary(const char* data, int length)
{
    char buf[MAX_PRINTED_BIN_LENGTH * 3 + 10] = {0};
    int i = 0;

    for (i = 0; i < length && i < MAX_PRINTED_BIN_LENGTH; i++)
    {
        sprintf(buf + i * 3, "%02X", data[i]);
        buf[i * 3 + 2] = ' ';   //because sprintf will add a terminating null character at the end
    }

    if (i >= MAX_PRINTED_BIN_LENGTH)
    {
        sprintf(buf + i * 3, "%s", "......\n");
    }
    printf("%s\n", buf);
}


